
import Head from 'next/head'

<Head>
  <script>
    {
      `(function() {
         var _hmt = _hmt || [];
(function() {
  var hm = document.createElement("script");
  hm.src = "https://hm.baidu.com/hm.js?e60fb290e204e04c5cb6f79b0ac1e697";
  var s = document.getElementsByTagName("script")[0]; 
  s.parentNode.insertBefore(hm, s);
})();
       })();`
    }
  </script>
</Head>

![LangChain](https://pica.zhimg.com/50/v2-56e8bbb52aa271012541c1fe1ceb11a2_r.gif)





阿勒夫·阿尔法[#](#aleph-alpha "到这个标题的永久链接")
=====================================

使用阿勒夫·阿尔法的语义嵌入有两种可能的方法。如果您有结构不同的文本（例如文档和查询)，则应使用不对称嵌入。相反，对于结构可比较的文本，建议使用对称嵌入。

不对称[#](#asymmetric "到这个标题的永久链接")
--------------------------------

```python
from langchain.embeddings import AlephAlphaAsymmetricSemanticEmbedding

```

```python
document = "This is a content of the document"
query = "What is the contnt of the document?"

```

```python
embeddings = AlephAlphaAsymmetricSemanticEmbedding()

```

```python
doc_result = embeddings.embed_documents([document])

```

```python
query_result = embeddings.embed_query(query)

```

对称[#](#symmetric "到这个标题的永久链接")
------------------------------

```python
from langchain.embeddings import AlephAlphaSymmetricSemanticEmbedding

```

```python
text = "This is a test text"

```

```python
embeddings = AlephAlphaSymmetricSemanticEmbedding()

```

```python
doc_result = embeddings.embed_documents([text])

```

```python
query_result = embeddings.embed_query(text)

```

